<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="org.json.simple.JSONObject"%>
<%@ page import="org.json.simple.JSONArray"%>
<%@ page import="java.net.URLEncoder"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	//String bcode=request.getParameter("bcode");

	String url="jdbc:oracle:thin:@192.168.0.18:1521:orcl";
	String user="book";
	String password="book";
	String sql=null;
	
	Connection conn=null;
	ResultSet rs=null;
	PreparedStatement stmt=null;
	
	try{
		Class.forName("oracle.jdbc.driver.OracleDriver");
		//out.println("드라이버 로딩 성공");
		conn=DriverManager.getConnection(url, user, password);
		//out.println("접속 성공");
		
		sql="select s.bcode, m.mcode, m.mnickname from sympathy s, member m where m.mcode=s.mcode order by s.sdate desc";
		//sql="select s.bcode, m.mcode, m.mnickname from sympathy s, member m where s.bcode=? and m.mcode=s.mcode order by s.sdate desc";
		
		stmt=conn.prepareStatement(sql);
		//stmt.setString(1, bcode);
		rs = stmt.executeQuery();
		
		JSONObject jsonMain=new JSONObject();
		JSONArray arr=new JSONArray();
		JSONArray arr1=new JSONArray();
		
	
		while(rs.next())
		{
			
			JSONObject obj=new JSONObject();
			String mcode=rs.getString("mcode");
			String mnickname=rs.getString("mnickname");
			String bcode1=rs.getString("bcode");
			
			obj.put("totalsymmcode", mcode);
			obj.put("totalsymmnickname", mnickname);
			obj.put("totalsymbcode", bcode1);
			
			arr.add(obj);
		
		}
		
		jsonMain.put("dataSend", arr);
		out.println(jsonMain);
		
	}catch(Exception e){
		out.println("접속 실패");
		e.printStackTrace();
	}finally{
		if(stmt!=null) stmt.close();
		if(conn!=null) conn.close();
	}
	
%>